package com.mt.grand.singleton.hungry;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

public class HungrySingletonTest {

    public static void main(String[] args) throws IOException {

        int count = 100;
        final CountDownLatch countDownLatch = new CountDownLatch(count);

        for(int i=0;i<count;i++){
            new Thread(new Runnable() {
                public void run() {
                    try {
                        countDownLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(HungrySingleton.getInstance());
                }
            }).start();
            countDownLatch.countDown();
        }

        System.in.read();
    }
}